package logic

import (
	"context"
	"home-manage/model"

	"home-manage/homerpc/homerpc"
	"home-manage/homerpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHouseAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseAddLogic {
	return &HouseAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *HouseAddLogic) HouseAdd(in *homerpc.HouseAddRequest) (*homerpc.HouseAddResponse, error) {
	// todo: add your logic here and delete this line

	house := model.House{

		Title:    in.Title,
		Lease:    in.Lease,
		Money:    float64(in.Money),
		Deposit:  in.Deposit,
		Num:      float64(in.Num),
		Facility: in.Facility,
		UserId:   int(in.UserId),
	}
	model.DB.Debug().Create(&house)
	return &homerpc.HouseAddResponse{
		HouseId: int64(house.ID),
	}, nil
}
